<?php

declare(strict_types=1);

use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET'], '/tt', 'App\Controller\Client\CommonController@tt');
Router::addRoute(['POST'], '/tt2', 'App\Controller\Client\CommonController@tt2');


//充值
Router::addRoute(
    ['GET', 'POST'],
    '/rechargePrepayH5',
    'App\Controller\Client\EmployerController@rechargePrepayH5'
);


Router::addRoute(
    ['POST'],
    '/rechargeCallback',
    'App\Controller\Client\EmployerController@rechargeCallback'
);


Router::addGroup(
    '/client',
    function () {
        Router::addGroup(
            '',
            function () {
                //手机登录，如果用户不存在则创建【phone：手机号码，code：验证码】
                Router::addRoute(['POST'], '/login/phone', 'App\Controller\Client\LoginController@loginUseCaptcha');
                //密码登录【phone：手机号码，password：密码】
                Router::addRoute(['POST'], '/login/password', 'App\Controller\Client\LoginController@loginUsePassword');
                //微信快捷登录【code：小程序的jscode值】
                Router::addRoute(['POST'], '/login/wechat', 'App\Controller\Client\LoginController@loginUseWx');
                //微信注册并登录【phone：手机号码，code：验证码，openid：微信用户openid】
                Router::addRoute(['POST'], '/register/wechat', 'App\Controller\Client\LoginController@registerUseWx');

                //获取客服电话
                Router::addRoute(['GET'], '/servicePhone', 'App\Controller\Client\CommonController@servicePhone');
            }
        );

        //用户端
        Router::addGroup(
            '',
            function () {
                //上传图片
                Router::addRoute(['POST'], '/upload', 'App\Controller\UploadController@upload');


                //获取验证信息
                Router::addRoute(
                    ['GET'],
                    '/certification/idcard',
                    'App\Controller\Client\CertificationController@idcardInfo'
                );

                //实名认证-个人【idcard：身份证号码，name：名字】
                Router::addRoute(
                    ['POST'],
                    '/certification/idcard',
                    'App\Controller\Client\CertificationController@idcard'
                );
                //实名认证-获取认证信息
                Router::addRoute(
                    ['GET'],
                    '/certification/company',
                    'App\Controller\Client\CertificationController@companyInfo'
                );

                //实名认证-企业【name：公司名称，credit_code：信用代码，license_img：营业执照图片】
                Router::addRoute(
                    ['POST'],
                    '/certification/company',
                    'App\Controller\Client\CertificationController@company'
                );

                //抽成比例
                Router::addRoute(
                    ['GET'],
                    '/commissionPercent',
                    'App\Controller\Client\CommonController@commissionPercent'
                );


                //个人信息
                Router::addRoute(['GET'], '/user', 'App\Controller\Client\UserController@info');
                //个人信息-修改【avatar：头像，nickname：昵称，sex：性别0保密1男2女，qq：qq，contact：联系电话，description：个性说明】
                Router::addRoute(['PUT'], '/user', 'App\Controller\Client\UserController@infoUpdate');
                //个人密码修改【password：新密码，password_confirmation：确认密码】
                Router::addRoute(
                    ['PUT'],
                    '/user/password',
                    'App\Controller\Client\UserController@infoPasswordUpdate'
                );
                //绑定支付宝【alipay：支付宝】
                Router::addRoute(['PUT'], '/user/alipay', 'App\Controller\Client\UserController@bindAlipay');
                //绑定微信openid
                Router::addRoute(['PUT'], '/user/openid', 'App\Controller\Client\UserController@bindOpenid');

                //金币列表-佣金明细/平台奖励明细【type：1佣金2平台奖励】
                Router::addRoute(['GET'], '/gold', 'App\Controller\Client\UserController@goldList');
                //金币提现【type：1佣金2平台奖励，gold：金币数】
                Router::addRoute(['POST'], '/withdraw', 'App\Controller\Client\UserController@withdraw');
                //金币提现列表
                Router::addRoute(['GET'], '/withdraw', 'App\Controller\Client\UserController@withdrawList');
                //等级规则
                Router::addRoute(['GET'], '/levelRule', 'App\Controller\Client\CommonController@levelRule');


                //任务类型
                Router::addRoute(['GET'], '/taskType', 'App\Controller\Client\CommonController@taskType');
                //banner列表
                Router::addRoute(['GET'], '/banner', 'App\Controller\Client\CommonController@banner');
                //发现页
                Router::addRoute(['GET'], '/discover', 'App\Controller\Client\CommonController@discover');


                //任务标签
                Router::addRoute(['GET'], '/tags', 'App\Controller\Client\TaskController@tags');
                //随机任务列表
                Router::addRoute(['GET'], '/tasks/random', 'App\Controller\Client\TaskController@random');
                //任务列表【search：查询词->标签和标题】
                Router::addRoute(['GET'], '/tasks', 'App\Controller\Client\TaskController@list');
                //任务详情【{id}：任务id】
                Router::addRoute(['GET'], '/tasks/{id}', 'App\Controller\Client\TaskController@info');
                //任务详情-所有领取用户【{id}：任务id】
                Router::addRoute(['GET'], '/tasks/{id}/users', 'App\Controller\Client\TaskController@receiver');
                //领取任务【id：任务id，gather_user_info：收集用户信息->通过任务是否开启判断是否收集】
                Router::addRoute(['POST'], '/userTask', 'App\Controller\Client\TaskController@receiveTask');
                //用户已领取任务列表【type：1正在倒计时2未提交已结束3已提交待审核4已提交通过5已提交未通过6仲裁待审7仲裁已审核】
                Router::addRoute(['GET'], '/userTask', 'App\Controller\Client\TaskController@receiveTaskList');

                //任务进度-详情【{id}：进度id】
                Router::addRoute(
                    ['GET'],
                    '/taskProcess/{id}',
                    'App\Controller\Client\TaskController@processInfo'
                );

                //通过主任务id获取领取详情
                Router::addRoute(
                    ['GET'],
                    '/task/{id}/receive',
                    'App\Controller\Client\TaskController@taskReceiverInfo'
                );

                //提交/修改任务【{id}：任务进度id，audit_image_0：提交图片0，audit_image_1：图片1，audit_image_2：图片2】
                Router::addRoute(
                    ['PUT'],
                    '/userTask/{id}/submit',
                    'App\Controller\Client\TaskController@receiveTaskSubmit'
                );
                //申请仲裁【{id}：任务进度id】
                Router::addRoute(
                    ['PUT'],
                    '/userTask/{id}/arbitrate',
                    'App\Controller\Client\TaskController@receiveTaskArbitrate'
                );


                //用户通知未读数
                Router::addRoute(
                    ['GET'],
                    '/userNoticeNotRead',
                    'App\Controller\Client\NoticeController@userNoticeNotRead'
                );
                //用户通知列表
                Router::addRoute(['GET'], '/userNotice', 'App\Controller\Client\NoticeController@userNotice');
                //悬赏主通知未读数
                Router::addRoute(
                    ['GET'],
                    '/employerNoticeNotRead',
                    'App\Controller\Client\NoticeController@employerNoticeNotRead'
                );
                //悬赏主通知列表
                Router::addRoute(['GET'], '/employerNotice', 'App\Controller\Client\NoticeController@employerNotice');
            },
            [
                'middleware' => [
                    \App\Middleware\ClientAuthMiddleware::class,
                    \App\Middleware\ClientUserMiddleware::class
                ]
            ]
        );

        //悬赏主端
        Router::addGroup(
            '',
            function () {
                //悬赏主信息
                Router::addRoute(['GET'], '/employer', 'App\Controller\Client\EmployerController@info');

                //充值
                Router::addRoute(
                    ['POST'],
                    '/rechargePrepay',
                    'App\Controller\Client\EmployerController@rechargePrepay'
                );

                //已注册平台列表
                Router::addRoute(['GET'], '/cooperatives', 'App\Controller\Client\EmployerController@cooperativeList');

                //任务统计【cooperative：运营商平台id->等于all即是查询全部平台，等于空即是查询当前平台】
                Router::addRoute(['GET'], '/taskStatistics', 'App\Controller\Client\TaskEmployerController@statistics');
                /**
                 * 发布任务
                 * cover_image：封面图
                 * title：标题
                 * product_name：产品名称
                 * description：任务要求
                 * audit_time：审核时间，单位小时
                 * price：单价
                 * end_time：任务截至时间：时间戳
                 * count：任务总数
                 * getter_user_info：是否收集用户信息：0否1是
                 * hint_message：收集用户信息框提示信息
                 *
                 * step_text_10：步骤一文本（最多3张图片）
                 * step_image_10：步骤一图片1
                 * step_image_11：步骤一图片2
                 * step_image_12：步骤一图片3
                 *
                 * step_text_20：步骤二文本1（最多5个）
                 * step_image_20：步骤二图片1
                 * step_text_21：步骤二文本2
                 * step_image_21：步骤二图片2
                 * step_text_22：步骤二文本3
                 * step_image_22：步骤二图片3
                 * step_text_23：步骤二文本4
                 * step_image_23：步骤二图片4
                 * step_text_24：步骤二文本5
                 * step_image_24：步骤二图片5
                 *
                 * step_text_30：步骤三文本1（最多3个）
                 * step_image_30：步骤三图片1
                 * step_text_31：步骤三文本2
                 * step_image_31：步骤三图片2
                 * step_text_32：步骤三文本3
                 * step_image_32：步骤三图片3
                 *
                 * user_finish_time：用户完成最大时间
                 * estimated_time：预估完成时间
                 * contact：联系方式
                 * tags：标签
                 */
                Router::addRoute(['POST'], '/employerTask', 'App\Controller\Client\TaskEmployerController@publish');
                //任务列表-悬赏主【status：1待审核2审核失败3审核通过4暂停/结束5已被领取】
                Router::addRoute(['GET'], '/employerTask', 'App\Controller\Client\TaskEmployerController@list');
                //被领取任务进度-列表【type：提交任务审核状态：1待审核2通过3失败，仲裁状态：4待审核5已审核】
                Router::addRoute(['GET'], '/taskProcess', 'App\Controller\Client\TaskEmployerController@processList');
                //任务进度审核【{id}：进度id，audit_status：审核状态1通过2失败，audit_fail_context：审核失败的描述】
                Router::addRoute(
                    ['PUT'],
                    '/taskProcess/{id}/audit_status',
                    'App\Controller\Client\TaskEmployerController@processAudit'
                );


                //任务修改【{id}：任务id，其他参数参考 发布任务】
                Router::addRoute(['PUT'], '/tasks/{id}', 'App\Controller\Client\TaskEmployerController@update');
                //任务修改-上/下架【{id}：任务id，status：0下架1上架】
                Router::addRoute(
                    ['PUT'],
                    '/tasks/{id}/show_status',
                    'App\Controller\Client\TaskEmployerController@updateShowStatus'
                );
                //任务退款【{id}：任务id】
                Router::addRoute(
                    ['PUT'],
                    '/tasks/{id}/refund',
                    'App\Controller\Client\TaskEmployerController@refund'
                );

                //账户明细
                Router::addRoute(['GET'], '/balance', 'App\Controller\Client\EmployerController@balance');
            },
            [
                'middleware' => [
                    \App\Middleware\ClientAuthMiddleware::class,
                    \App\Middleware\ClientEmployerMiddleware::class
                ]
            ]
        );
    },
    [
        'middleware' => [
            \App\Middleware\ClientMiddleware::class,
        ]
    ]
);